package com.ruoyi.movie.service.impl;

import com.ruoyi.movie.domain.VideoResource;
import com.ruoyi.movie.mapper.VideoResourceMapper;
import com.ruoyi.movie.service.IVideoResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 视频资源Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-22
 */
@Service
public class VideoResourceServiceImpl implements IVideoResourceService {

    @Autowired
    private VideoResourceMapper videoResourceMapper;

    /**
     * 查询视频资源
     *
     * @param resourceId 视频资源主键
     * @return 视频资源
     */
    @Override
    public VideoResource selectVideoResourceById(Long resourceId) {
        return videoResourceMapper.selectVideoResourceById(resourceId);
    }

    /**
     * 查询视频资源列表
     *
     * @param videoResource 视频资源
     * @return 视频资源集合
     */
    @Override
    public List<VideoResource> selectVideoResourceList(VideoResource videoResource) {
        return videoResourceMapper.selectVideoResourceList(videoResource);
    }

    /**
     * 根据视频ID查询资源列表
     *
     * @param videoId 视频ID
     * @return 视频资源集合
     */
    @Override
    public List<VideoResource> selectVideoResourceByVideoId(Long videoId) {
        return videoResourceMapper.selectVideoResourceByVideoId(videoId);
    }

    /**
     * 新增视频资源
     *
     * @param videoResource 视频资源
     * @return 结果
     */
    @Override
    public int insertVideoResource(VideoResource videoResource) {
        return videoResourceMapper.insertVideoResource(videoResource);
    }

    /**
     * 批量新增视频资源
     *
     * @param videoResources 视频资源列表
     * @return 结果
     */
    @Override
    public int batchInsertVideoResource(List<VideoResource> videoResources) {
        if (videoResources == null || videoResources.isEmpty()) {
            return 0;
        }
        return videoResourceMapper.batchInsertVideoResource(videoResources);
    }

    /**
     * 修改视频资源
     *
     * @param videoResource 视频资源
     * @return 结果
     */
    @Override
    public int updateVideoResource(VideoResource videoResource) {
        return videoResourceMapper.updateVideoResource(videoResource);
    }

    /**
     * 批量删除视频资源
     *
     * @param resourceIds 需要删除的视频资源主键集合
     * @return 结果
     */
    @Override
    public int deleteVideoResourceByIds(Long[] resourceIds) {
        return videoResourceMapper.deleteVideoResourceByIds(resourceIds);
    }

    /**
     * 删除视频资源信息
     *
     * @param resourceId 视频资源主键
     * @return 结果
     */
    @Override
    public int deleteVideoResourceById(Long resourceId) {
        return videoResourceMapper.deleteVideoResourceById(resourceId);
    }

    /**
     * 根据视频ID删除资源
     *
     * @param videoId 视频ID
     * @return 结果
     */
    @Override
    public int deleteVideoResourceByVideoId(Long videoId) {
        return videoResourceMapper.deleteVideoResourceByVideoId(videoId);
    }

    /**
     * 根据影视ID查询资源列表
     *
     * @param movieId 影视ID
     * @return 视频资源集合
     */
    @Override
    public List<VideoResource> selectVideoResourceListByMovieId(Integer movieId) {
        VideoResource query = new VideoResource();
        query.setMovieId(movieId);
        return videoResourceMapper.selectVideoResourceList(query);
    }

    /**
     * 根据影视ID删除所有视频资源
     *
     * @param movieId 影视ID
     * @return 结果
     */
    @Override
    public int deleteVideoResourceListByMovieId(Integer movieId) {
        return videoResourceMapper.deleteVideoResourceByMovieId(movieId);
    }
}